package tongwentongshu.com.app.activity;

import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
import tongwentongshu.com.app.R;
import tongwentongshu.com.app.adapter.MyShareDetailsAdapter;
import tongwentongshu.com.app.adapter.NullAdapter;
import tongwentongshu.com.app.bean.MessageReadBean;
import tongwentongshu.com.app.bean.ShareDetailsBean;
import tongwentongshu.com.app.contract.MyMessageContract;
import tongwentongshu.com.app.contract.MyShareDetailsContract;
import tongwentongshu.com.app.db.DataKeeper;
import tongwentongshu.com.app.presenter.MyMessagePresenter;
import tongwentongshu.com.app.presenter.MyShareDetailsPresenter;
import tongwentongshu.com.app.utils.GlideUtil;

/**
 * Created by XiongBin on 2017/7/18.
 */

public class MyMessageActivity extends BaseActivity implements MyMessageContract.View, BaseQuickAdapter.RequestLoadMoreListener, SwipeRefreshLayout.OnRefreshListener {

    @BindView(R.id.rv_list)
    RecyclerView mRecyclerView;
    @BindView(R.id.swipeLayout)
    SwipeRefreshLayout mSwipeRefreshLayout;
    //通知消息
    @BindView(R.id.tv_msg_notice_content)
    TextView noticeContent;
    @BindView(R.id.tv_msg_notice_time)
    TextView noticeTime;
    @BindView(R.id.iv_red_dot_1)
    ImageView noticeDot;
    //互动消息
    @BindView(R.id.tv_msg_interaction_content)
    TextView interactionContent;
    @BindView(R.id.tv_msg_interaction_time)
    TextView interactionTime;
    @BindView(R.id.iv_red_dot_2)
    ImageView interactionDot;


    private MyMessagePresenter myMessagePresenter;

    @Override
    protected int getLayoutResourceId() {
        return R.layout.activity_my_message;
    }

    @Override
    protected int getTitleId() {
        return R.string.my_message;
    }

    MessageReadBean bean;

    @Override
    protected void initView() {
        bean = (MessageReadBean) DataKeeper.readSerializable(mContext, MessageReadBean.class);
        interactionContent.setText(bean.getData().getInteraction_title());
        interactionTime.setText(bean.getData().getInteraction_time());
        noticeContent.setText(bean.getData().getSystem_title());
        noticeTime.setText(bean.getData().getSystem_time());
        if (bean.getData().getIs_interaction() == 1) {
            interactionDot.setVisibility(View.VISIBLE);
        } else {
            interactionDot.setVisibility(View.GONE);
        }
        if (bean.getData().getIs_system() == 1) {
            noticeDot.setVisibility(View.VISIBLE);
        } else {
            noticeDot.setVisibility(View.GONE);
        }
    }

    @OnClick({R.id.rel_msg_interaction, R.id.rel_msg_notice})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.rel_msg_interaction:
                Bundle ib = new Bundle();
                ib.putString("type", "2");
                startActivity(MyMessageListActivity.class, ib);
                break;
            case R.id.rel_msg_notice:
                Bundle nb = new Bundle();
                nb.putString("type", "1");
                startActivity(MyMessageListActivity.class, nb);
                break;
        }
    }

    @Override
    protected void initData() {
        myMessagePresenter = new MyMessagePresenter(this);
    }


    @Override
    public void onRefresh() {
        onRefreshJudge = true;
    }

    @Override
    public void onLoadMoreRequested() {

    }
}
